package com.wensen.biz;

import com.wensen.entity.BankInfo;
import com.wensen.feigin.ProductFeign;
import com.wensen.mapper.BankInfoMapper;
import com.wensen.ribbitmq.RibbitMqSender;
import com.wensen.service.BankInfoService;
import entity.EmailInfo;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
@RequestMapping("/user")
public class UserController {
    @Autowired
    ProductFeign feign;

    @Autowired
    private RibbitMqSender ribbitMqSender;

    @Autowired
    BankInfoService bankInfoService;

    @RequestMapping("/getUserInfo")
    @ResponseBody
    public String getUserName(){
        EmailInfo info = new EmailInfo();
        info.setId(1111L);
        info.setMessage("222222");
        ribbitMqSender.send(info);

        bankInfoService.updateBankInfoById(1);

        return "zhangsan";
    }

    @RequestMapping("/getProductInfo")
    @ResponseBody
    public String getProductInfo(){
        bankInfoService.updateBankInfoById(1);
        System.out.println("zhangsan-100 success");

        return "success";
    }

    @RequestMapping("/getBankInfoById")
    @ResponseBody
    public Object getUserName(int id){
        Object o = bankInfoService.getById(id);
        return o;
    }
}
